home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / ax25mail.c < prev    next >
C/C++ Source or Header  |  1994-06-04  |  2KB  |  93 lines

  1. /* AX25 mailbox interface
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  *
  4.  *    May '91    Bill Simpson
  5.  *        move to separate file for compilation & linking
  6.  */
  7. #include "global.h"
  8. #include "proc.h"
  9. #include "iface.h"
  10. #include "pktdrvr.h"
  11. #include "ax25.h"
  12. #include "usock.h"
  13. #include "socket.h"
  14. #include "session.h"
  15. #include "mailbox.h"
  16. #include "ax25mail.h"
  17.  
  18. extern int Mbjumpstart;
  19.  
  20. /* Axi_sock is kept in Socket.c, so that this module won't be called */
  21.  
  22. int
  23. ax25start(argc,argv,p)
  24. int argc;
  25. char *argv[];
  26. void *p;
  27. {
  28.     int s,whatcall;
  29.     struct usock *up;
  30.  
  31.     if (Axi_sock != -1)
  32.         return 0;
  33.  
  34.     psignal(Curproc,0);    /* Don't keep the parser waiting */
  35.     chname(Curproc,"AX25 listener");
  36.     Axi_sock = socket(AF_AX25,SOCK_STREAM,0);
  37.     /* bind() is done automatically */
  38.     if(listen(Axi_sock,1) == -1){
  39.         close_s(Axi_sock);
  40.         return -1;
  41.     }
  42.     for(;;){
  43.         if((s = accept(Axi_sock,NULLCHAR,NULLINT)) == -1)
  44.             break;    /* Service is shutting down */
  45.  
  46. #ifdef notdef
  47.         /* THIS is now done in LAPB.C - WG7J */
  48.         if(availmem() < Memthresh + 5120L) {
  49.             shutdown(s,1);
  50.         } else {
  51. #endif
  52.  
  53.             /* Spawn a server */
  54.             up = itop(s);
  55.             whatcall = up->cb.ax25->jumpstarted;
  56.             /* If jumpstart is off, then
  57.              * eat the line that triggered the connection
  58.              * and start the mailbox
  59.              */
  60.             if(!Mbjumpstart) {
  61.                 sockmode(s,SOCK_ASCII);    /* To make recvline work */
  62.                 recvline(s,NULLCHAR,80);
  63.             } else {
  64.                 /* Check to see if jumpstart was actually used for
  65.                  * this connection.
  66.                  * If not, then again eat the line triggering this all
  67.                  */
  68.                 if(!(whatcall&JUMPSTARTED)) {
  69.                     sockmode(s,SOCK_ASCII);    /* To make recvline work */
  70.                     recvline(s,NULLCHAR,80);
  71.                 }
  72.             }
  73.             if(newproc("mbox",2048,mbx_incom,s,(void *)whatcall,NULL,0) == NULLPROC)
  74.                 close_s(s);
  75. #ifdef notdef
  76.         }
  77. #endif
  78.     }
  79.     close_s(Axi_sock);
  80.     Axi_sock = -1;
  81.     return 0;
  82. }
  83. int
  84. ax250(argc,argv,p)
  85. int argc;
  86. char *argv[];
  87. void *p;
  88. {
  89.     close_s(Axi_sock);
  90.     Axi_sock = -1;
  91.     return 0;
  92. }
  93.